package com.zh.note.huawei.onehundred.星际篮球争霸赛;



import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        if (t < 1 || t > 50) {
            return;
        }
        int[] socre = new int[t];
        for (int i = 0; i < socre.length; i++) {
            socre[i] = sc.nextInt();
        }
        int sum = 0;
        for (int item : socre) {
            sum += item;
        }

        for (int j = socre.length; j > 0; j--) {
            int[] bucket = new int[j + 1];
            if (sum % j == 0 && canThreePartsEqualSum(socre, sum / j, j, 0, bucket)) {
                System.out.println(sum / j);
                break;
            }
        }
        // int[] nums = {5, 2, 1, 5, 2, 1, 5, 2, 1};
        // int[] bucket = new int[5];
        // System.out.println(canThreePartsEqualSum(nums, 6, 4, 0, bucket));
    }

    /**
     * 如何将一个列表分成若干个子集合，使得每个子集合的元素之和相等
     */
    private static boolean canThreePartsEqualSum(int[] socre, int target, int k, int index, int[] bucket) {
        if (index == socre.length) {
            for (int i = 0; i < k; i++) {
                if (bucket[i] != target) {
                    return false;
                }
            }
            return true;
        }
        for (int i = 0; i < k; i++) {
            if (bucket[i] + socre[index] > target) {
                continue;
            }
            if (i > 0 && bucket[i] == bucket[i - 1]) {
                continue;
            }

            bucket[i] += socre[index];
            if (canThreePartsEqualSum(socre, target, k, index + 1, bucket)) {
                return true;
            }
            bucket[i] -= socre[index];
        }
        return false;
    }
}
